package com.meilele.controller.zhengchao;

import com.meilele.biz.zhengchao.ArticleBiz;
import com.meilele.biz.zhengchao.ContentBiz;
import com.meilele.entity.zhengchao.FourArticle;
import com.meilele.entity.zhengchao.FourContent;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("/content")
public class ContentContrller {
    @Resource
    private ContentBiz biz;
    @Resource
    private ArticleBiz bi;

    /**
     * 装修攻略:展示文章内容
     * @param id:文章的id
     * @param request
     * @return :跳转detail页面
     */
    @RequestMapping("/findById/{id}")
    public String findByContentId(@PathVariable("id") int id, Map<String,Object> request){
       FourArticle four= bi.findById(id);
       int aaa=four.getFourContent().getContentId();
      FourContent aa=biz.findByContentId(aaa);
        Integer bb=four.getArticleReader()+1;
        bi.updateReadById(id,bb);
      request.put("content",aa);
      return "four/detail";
    }
}
